import { DEFAULT_PRIMARY, piniaPersistConfig } from "@/config";
import type { GlobalStoreConfig } from "@/typings";
import { defineStore } from "pinia";
import { reactive, ref } from "vue";

const key: string = "useGlobalStore";

export const useGlobalStore = defineStore(
  key,
  () => {
    const globalConfig: GlobalStoreConfig = reactive({
      language: null,
      primary: DEFAULT_PRIMARY,
      maximize: false,
      isDark: false,
      isCollapse: false,
      breadcrumb: true,
      breadcrumbIcon: true,
      tabs: true,
      tabsIcon: true,
      footer: false,
      openDrawer: false,
      isPanorama: false,
      assemblySize: "default"
    });

    const date = ref<string>("");
    return {
      globalConfig,
      date
    };
  },
  {
    persist: piniaPersistConfig(key, localStorage, ["globalConfig"])
  }
);
